package com.share.example.sbnfsj;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@ServletComponentScan   //配置servlet扫描
@EnableFeignClients     //开启feign
@EnableDiscoveryClient   //服务发现与注册
@SpringBootApplication(exclude = {MongoAutoConfiguration.class, FreeMarkerAutoConfiguration.class})
public class AppSbnfsj extends SpringBootServletInitializer {

    /*配置使用war的方式启动*/
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(AppSbnfsj.class);
    }

    public static void main(String[] args) {
        SpringApplication.run(AppSbnfsj.class, args);
    }

    /*开启riboon的负载均衡*/
    @Bean
    @LoadBalanced
    RestTemplate restTemplate() {
        return new RestTemplate();
    }

    @RequestMapping("/test")
    Object te() {
        return "new RestTemplate()";
    }
}